获取win10启动墙纸 procedure TForm2.Button2Click(Sender: TObject);
var
Jpeg: TJPEGImage;
begin
Jpeg := TJPEGImage.Create;
try
SavePictureDialog1.Execute;
if SavePictureDialog1.FileName <> '' then
begin
Jpeg.Assign(image1.Picture.Bitmap);
Jpeg.SaveToFile(SavePictureDialog1.FileName);
end;
finally
Jpeg.free;
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
var
Jpeg: TJPEGImage;
Reg: Tregistry; {Tregistry 对象在Registry 单元中声明,需用Uses令引用Registry单元}
begin
Jpeg := TJPEGImage.Create;
try
Jpeg.Assign(image1.Picture.Bitmap);
Jpeg.SaveToFile(LabeledEdit1.Text '\' 'temp.jpg');
finally
Jpeg.free;
end;
Reg := TRegistry.Create; {创建Tregistry对象的实例}
Reg.Rootkey := Hkey_Current_User; {设置根键名称}
Reg.OpenKey('\Control Panel\Desktop', False); {打开Control Panel/Desktop 路径对应的主键}
Reg.WriteString('TileWallpaper', '0'); {向TileWallpaper 和Wallpaper串覆盖写入新值}
Reg.WriteString('WallPaperStyle', '0'); {向TileWallpaper 和Wallpaper串覆盖写入新值}
Reg.WriteString('Wallpaper', LabeledEdit1.Text '\' 'temp.jpg'); {向TileWallpaper 和Wallpaper串覆盖写入新值}
Systemparametersinfo(SPI_SETDESKWallpaper, 0, Nil, SPIF_SendChange); {向Windows发送消息,通知Windows更换壁纸}
Reg.CloseKey; {将更改内容写入注册表并关闭}
Reg.Free; {释放对象}
end;
评论